#include "dataservers.h"

DataServers* DataServers::instance = new DataServers();

DataServers::DataServers(const QString &dbname, QObject *parent)
    : QObject(parent)
{
    connect(dbname);
}

std::pair<QSqlQuery, bool> DataServers::query(const QString &sql)
{
    if(!db.isOpen ())
        return std::make_pair(QSqlQuery(nullptr), false);
    QSqlQuery query = db.exec (sql);

    QSqlError error = db.lastError ();
    if(error.isValid ()){
        qDebug() << error.text () << ":[[" << sql <<"]]";
        return std::make_pair(QSqlQuery(nullptr), false);
    }

    return std::make_pair(std::move(query), true);
}

bool DataServers::load (const QString &dbname)
{
    close();
    connect (dbname);
}
